import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '*',
    component: () => import(/* webpackChunkName: "Index" */ '../views/Index.vue'),
  },
  {
    path: '/index/',
    name: 'index',
    meta: {},
    component: () => import(/* webpackChunkName: "Index" */ '../views/Index.vue'),
  },
  {
    path: '/caseList',
    name: 'caseList',
    meta: {
      title: '事项列表'
    },
    component: () => import(/* webpackChunkName: "CaseList" */ '../views/CaseList.vue'),
  },
  {
    path: '/handleOnline',
    name: 'handleOnline',
    meta: {
      title: '在线办理'
    },
    component: () => import(/* webpackChunkName: "HandleOnline" */ '../views/handleOnline/HandleOnline.vue'),
    children: [
      {
        path: '/upload',
        name: 'upload',
        meta: {
          title: '上传材料'
        },
        component: () => import(/* webpackChunkName: "Upload" */ '@/views/Upload.vue'),
      },
      {
        path: '/success',
        name: 'success',
        meta: {
          title: '提交成功'
        },
        component: () => import(/* webpackChunkName: "Success" */ '@/views/Success.vue'),
      },
    ]
  },
];

const router = new VueRouter({
  routes
});

router.beforeEach((to, from, next) => {
  if (to.params.pathCode === 'ylbxgxzr') {
    next('/endowment-insurance');
    return
  }
  next()
})

export default router
